using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using IntegratedMeasuring.ViewModels.Scheme;
using System.Collections.Generic;
using Avalonia.Collections;

namespace IntegratedMeasuring.Pages;

public partial class TestConditionPreviewDialog : Window
{
    public TestConditionPreviewDialog(TestConditions testConditions)
    {
        InitializeComponent();
        FileNameText.Text = testConditions.Name ?? "(无名称)";
        // 分组并绑定DataGrid
        var beautifyData = testConditions?.BeautifyData ?? new List<TransItemData>();
        var view = new DataGridCollectionView(beautifyData);
        DataGrid.ItemsSource = view;
    }

    private void CloseButton_Click(object? sender, RoutedEventArgs e)
    {
        
        this.Close(new {result=false, name=FileNameText.Text});
    }

    private void SaveButton_Click(object? sender, RoutedEventArgs e)
    {
        this.Close(new {result=true, name=FileNameText.Text});
    }

    private void CancelButton_Click(object? sender, RoutedEventArgs e)
    {
        this.Close(new {result=false, name=FileNameText.Text});
        
    }
    // public DataGrid TestConditionsDataGrid => this.FindControl<DataGrid>("TestConditionsDataGrid");
}
